package com.yedean.factory.aop.framework;

import com.yedean.factory.aop.AdvisedSupport;

public class ProxyFactory {
    
    private AdvisedSupport advisedSupport;


    public ProxyFactory(AdvisedSupport advisedSupport) {
        this.advisedSupport = advisedSupport;
    }
    
    public Object getProxy(){
        return createProxy().getProxy();
    }
    private AopProxy createProxy(){
        if (advisedSupport.isProxyTargetClass()){
            return new Cglib2AopProxy(advisedSupport);
        }else {
            return new JDKDynamicAopProxy(advisedSupport);
        }
    }
}
